package com.dxy.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dxy.common.pojo.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface ProductMapper extends BaseMapper<Product> {

    @Update("update t_product set product_num = product_num - #{num} where pid = #{productId} and product_num >= #{num}")
    int reduceStock(@Param("productId") String productId, @Param("num") int num);
}
